home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / IM_Install3.adf / piarc.LZH / launch.rexx < prev    next >
OS/2 REXX Batch file  |  1992-02-29  |  3KB  |  99 lines

  1. /*
  2.  * launch.rexx  a P.I. module to launch another script using the 
  3.  *               image processor's list requester
  4.  *               
  5.  *
  6.  *  Written by: Barry Chalmers
  7.  * Last Update: March 3rd, 1992
  8.  *    Revision: 1.01
  9.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  10.  */
  11.  
  12. parse arg firstarg ',' secondarg
  13.  
  14. /*
  15.  * open rexxsupport.library -- needed for some functions
  16.  */
  17. if ~show('L',"rexxsupport.library") then do
  18.   if addlib('rexxsupport.library',0,-30,0) then do
  19.       /* everything's ok */
  20.     end;
  21.   else do
  22.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  23.     say 'Cannot operate RESOLVER.rexx without this library - sorry!';
  24.     exit 10;
  25.     end;
  26.   end;
  27.  
  28. /*
  29.  * This will automatically direct the script to the proper
  30.  * software, if it is running. No matter where the script is
  31.  * launched from. :^) I sure do like ARexx. :^))
  32.  */
  33. prtnme = 'IP_Port'; /* assume Image Professional */
  34. if show('P','IP_Port') = 0 then do
  35.   if show('P','IM_Port') = 0 then do
  36.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  37.     say "This script requires IP, IM or IM F/c to run!";
  38.     exit(20);
  39.     end;
  40.   else do
  41.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  42.     end;                 /* We make em, user's break em.          */
  43.   end;
  44.  
  45.   /*
  46.    * This code attempts to read a file called "picmdpath" from REXX:
  47.    * If it can't find it, the script will assume that the commands
  48.    * associated with this PI Module are in "c:". If the file exists,
  49.    * the script will look in the path that is specified in the file.
  50.    * If you create this file, you MUST put a complete, correct path
  51.    * in it; if the commands are in a sub-directory, you have to put
  52.    * the trailing slash on the path (like, device:dir/).
  53.    * 
  54.    */
  55.   cmdpath = 'c:';
  56.   if open(fhandle,'rexx:picmdpath','read') then  /* open the file */
  57.     do
  58.       cmdpath = readln(fhandle);
  59.       call close(fhandle);  /* close the file    */
  60.     end
  61.  
  62. address(prtnme);
  63.  
  64. prevgfunc = '';
  65. if show('C',prefunk) = 1 then
  66.   do
  67.     prevgfunc = getclip(prefunk);
  68.   end;
  69.  
  70. if firstarg = '' then 
  71.   do
  72.     'message "The Script Launcher requires a LIST name"';
  73.   end
  74.  
  75. options results
  76. 'listreq "Launch a P.I. Module","'||cmdpath||firstarg||'",'||secondarg
  77. tname = result
  78. options
  79.  
  80. if tname = '' then 
  81.   do
  82.     exit 0;
  83.   end
  84.  
  85. name = "rxpi:"||tname   /* Let the OS handle the .rexx extension */
  86.  
  87. parse var name rname ':' fname '.' ename
  88.  
  89. if ename = 'rexx' then
  90.   do
  91.     call setclip(prefunk,fname);
  92.   end
  93. /*
  94.  * This should simply launch the requested script:
  95.  */
  96. address command 'rx '||name
  97.  
  98. exit 0;
  99.